#ifndef __SHELL_H
#define __SHELL_H

#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <map>
#include <algorithm>
#include <functional>


//classes:
#include "Node.h"
#include "Mailer.h"
#include "Messenger.h"
#include "Message.h"

// Functor for deleting pointers in map.
template<class A, class B>
struct DeleteMapFntor
{
    // Overloaded () operator.
    // This will be called by for_each() function.
    bool operator()(pair<A,B> x) const
    {
        // Assuming the second item of map is to be
        // deleted. Change as you wish.
        delete x.second;
        return true;
    }
};


class Shell:public Messenger{
private:
    map<int,Node*> nodes;
    int mailerBufferSize;
    Mailer * mailer;

    void waitForIT();
protected:
    void handleSysMsg(Message* msg);
    void handleRTMsg(Message* msg);
    void handleMsg(Message* msg);

public:
    //ctor:
    Shell();
    virtual ~Shell();

    void go();
    void printMenu();
    void createNet(string filename);
    void killNode(int id);
    void killAll();
    void revive();
    void printRT(int id);
    void sendPacket();
    void run(int scheduleNum, void* args);


};
#endif
